package dbdemo.mongo.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

@Document(collection = "user")
@Data
@JsonIgnoreProperties({"_class"})
public class User {

    @Id
    private Long id;
    private String name;

    @Indexed(unique = true)
    private String username;
    private String password;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createdate = new Date();
    private Set<String> roles = new HashSet<>();

}
